package testshop.dao;

import testshop.db.DbClose;
import testshop.db.DbConn;
import testshop.entity.SalesMan;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

/**
 * java类简单作用描述
 *
 * @ProjectName: test.zc.shopLearning
 * @Package: testshop.dao
 * @ClassName: ${TYPE_NAME}
 * @Description: java类作用描述
 * @Author: 周灿
 * @CreateDate: 2018/3/19 18:11
 * @UpdateUser: Can.Zhou
 * @UpdateDate: 2018/3/19 18:11
 * @UpdateRemark: The modified content
 * @Version: 1.0
 * <p>
 * Copyright: Copyright (c) by 周灿 on 2018-03-19
 */
public final class SalesManDao {

    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;


    public ArrayList<SalesMan> checkStandLog(String sName){

        ArrayList<SalesMan> list = new ArrayList<SalesMan>();

        conn = DbConn.getconn();

        String sql = "SELECT sid,spassword FROM salesman WHRER sname = ?";

     try{
         pstmt = conn.prepareStatement(sql);
         pstmt.setString(1,sName);

         rs = pstmt.executeQuery();
         while (rs.next()){

             String passw = rs.getString("spassword");
             int  sid = rs.getInt("sid");

             SalesMan man = new SalesMan(sid,passw);

             list.add(man);


         }





     }catch (SQLException e){
         e.printStackTrace();
     }finally {
         DbClose.queryClose(pstmt,rs,conn);
     }


    return  list;



    }










}
